﻿<UserControl
    x:Class="SuperQuiz.View.QuizLinksListControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:SuperQuiz.View"
    xmlns:common="using:SuperQuiz.Common"
    xmlns:utils="using:SuperQuiz.Utils"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400"
    x:Name="quizLinksListControl">

    <UserControl.Resources>
        <utils:StringToUriConverter x:Key="StringToUriConverter" />
        <utils:CollectionEmptyToVisibilityConverter x:Key="CollectionEmptyToVisibilityConverter" />
    </UserControl.Resources>
    <Grid>
        <ListView Visibility="{Binding DataContext, ElementName=quizLinksListControl, Converter={StaticResource CollectionEmptyToVisibilityConverter}}" ItemsSource="{Binding DataContext, ElementName=quizLinksListControl}" SelectionMode="None" Style="{StaticResource NoScrollListView}">
            <ListView.ItemTemplate>
                <DataTemplate>
                    <HyperlinkButton Content="{Binding Title}" NavigateUri="{Binding Url, Converter={StaticResource StringToUriConverter}}" />
                </DataTemplate>
            </ListView.ItemTemplate>
            <ListView.Header>
                <Grid>
                    <TextBlock Text="Links" x:Uid="LinksTextBlock" Style="{StaticResource TitleTextStyle}"/>
                </Grid>
            </ListView.Header>
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="ListViewItem">
                                <ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}" ContentTransitions="{TemplateBinding ContentTransitions}" Content="{TemplateBinding Content}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
    </Grid>
</UserControl>